import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class LoginItem extends StatefulWidget {
  final Widget prefixIcon;
  final String hintText;
  final TextEditingController controller;
  final bool obscureText;

  LoginItem({
    Key key,
    this.prefixIcon,
    this.hintText,
    this.controller,
    this.obscureText = false
  }): super(key: key);

  @override
  State<StatefulWidget> createState() => MyState();
}

class MyState extends State<LoginItem> {

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return Container(
      width: 600.w,
      height: 100.w,
      margin: EdgeInsets.only(bottom: 30.w),
      child: TextField(
        obscureText: widget.obscureText,
        controller: widget.controller,
        keyboardType: TextInputType.emailAddress,
        style: TextStyle(fontSize: 14, color: Colors.black),//输入文本的样式
        decoration: InputDecoration(
          prefixIcon: Container(
            padding: EdgeInsets.all(15),
            child: widget.prefixIcon,
          ),
          // hintText: "用户名或邮箱",
          hintText: widget.hintText,
          hintStyle: TextStyle(color: Color(0xFFC8C8D9), fontSize: 14),
          contentPadding: EdgeInsets.fromLTRB(95.w, 0, 10, 15),
          fillColor: Color(0XFFF0F4FA),
          filled: true,
          enabledBorder: OutlineInputBorder(
            borderRadius: BorderRadius.all(
              Radius.circular(55.w), //边角为5
            ),
            borderSide: BorderSide(
              color: Colors.white, //边线颜色为白色
              width: 1, //边线宽度为1
            ),
          ),
          focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(
              color: Colors.white, //边框颜色为白色
              width: 1, //宽度为5
            ),
            borderRadius: BorderRadius.all(
              Radius.circular(55.w), //边角为30
            ),
          ),
        ),
      ),
    );
  }
}